from core.mysql import SessionLocal


def get_db_session():
    """
    依赖注入数据链接
    :return:
    """
    db = SessionLocal()
    try:
        yield db
        db.commit()
    except Exception as e:
        print(e)
        db.rollback()
        raise e
    finally:
        db.close()
